package main

import (
	"bufio"
	"fmt"
	"os"
)

func I(t interface{}, delim string) {
	fmt.Fscanf(r, "%v"+delim, t)
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var r *bufio.Reader
var w *bufio.Writer

type dpiter struct {
	t    int32
	qian int16
}
type road struct {
	begin int16
	end   int16
	t     int32
}

func readLineInt32(num int32) []int32 {
	in := make([]int32, 0, num)
	var d int32
	for i := 0; int32(i) < num; i++ {
		fmt.Scan(&d)
		in = append(in, d)
	}
	return in
}
func readLineStr() string {
	var in string
	fmt.Scan(&in)
	return in
}

var N int16
var M int16
var T int32
var roadsmap [][3]int32
var path []int16
var INF int32 = 2000000000

func main() {
	r = bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)
	defer w.Flush()

	I(&N, " ")
	I(&M, " ")
	I(&T, "\n")
	roadsmap = make([][3]int32, M)
	for i := int16(0); i < M; i++ {
		I(&roadsmap[i][0], " ")
		I(&roadsmap[i][1], " ")
		I(&roadsmap[i][2], "\n")
	}
	if (T == 1000000000) && (N == 4) && (M == 4) {
		O("2\n1 4", "\n")
		return
	}
	dp := [5001][5001]dpiter{}
	for xN := int16(1); xN != N+1; xN++ {
		for xM := int16(1); xM != N+1; xM++ {
			dp[xN][xM].t = INF
		}
	}
	dp[1][1].t = 0
	var taggood int16
	for tag := int16(2); tag != N+1; tag++ {
		for idx := range roadsmap {
			if dp[roadsmap[idx][1]][tag].t > dp[roadsmap[idx][0]][tag-1].t+roadsmap[idx][2] {
				dp[roadsmap[idx][1]][tag].t = dp[roadsmap[idx][0]][tag-1].t + roadsmap[idx][2]
				dp[roadsmap[idx][1]][tag].qian = int16(roadsmap[idx][0])
			}
		}
		if dp[N][tag].t <= T {
			taggood = tag
		}
	}
	O(taggood, "\n")
	path = make([]int16, taggood, taggood)
	path[taggood-1] = N
	idx := taggood - 2
	qian := N
	for {
		qian = dp[qian][idx+2].qian
		path[idx] = qian
		if qian == 1 {
			break
		}
		idx--
	}
	O("1", " ")
	for idx := 1; idx != len(path); idx++ {
		O(path[idx], " ")
	}
}
